# 构建假数据
var nums = [1,3,5,6];
var target = 5;

# 二分法函数
function searchInsert(nums, target){
    var left = 0;
    var right = nums.length();
    for(left < right){
        var mid = (left + right) / 2;
        if (target <= nums[mid]) {
        	right = mid;
        }else {
        	left = mid+1;
        }
    }
    return left;
}

# 执行并打印结果
print(searchInsert(nums, target));